<?php
/*  goat-cms : tumbleblog content management system
    Copyright (C) 2008 Thomas Purnell tom@thomaspurnell.com

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.*/

	include ("db_axs.php");
	$sType = $_POST[ 'sType' ];
	$type = "";
	switch( $sType ){
		case "subAudio":
			$type = "Audio";
			break;
		case "subImage":
			$type = "Image";
			break;
		case "subQuote":
			$type = "Quote";
			break;
		case "subLink":
			$type = "Link";
			break;
		case "subVideo":
			$type = "Video";
			break;
		case "subManual":
			$type = "Manual";
			break;
		default:
			unset( $type );
	}
	if ( isset( $type ) )
		db_add_entry( date( "Y-m-d H:i:s" ), $_POST['sTitle'], $type, $_POST['sSourceText'], $_POST['sSourceURL'], $_POST['sCaption'], $_POST['sContentA']);
?><html>
	<head>
		<style>
			body {
				background: #000;
				color: #fff;
				font-family: sans-serif;

			}
			#container {
				width: 640px;
				margin: 0 auto;
				text-align: left;
			}

			.example {
				font-size: small;
				color: #aaa;
				margin-left: 10px;
			}
			input {
				width: 250px;
			}
			.gc_s_menu_option {
				font-size: x-large;
			}
			span.gc_s_menu_option:hover {
				color: #000;
				background: white;
				cursor: pointer;
			}
			textarea {
				width: 250px;
			}

		</style>
		<script>
			var menus = new Array();

			function init(){
				populateMenus();
				setVisibleForm( 0 );
			}

			function populateMenus(){
				//Insert menu objects into menus array
				menus.push( generateMenuObject( "Audio" ) );
				menus.push( generateMenuObject( "Image" ) );
				menus.push( generateMenuObject( "Quote" ) );				
				menus.push( generateMenuObject( "Video" ) );
				menus.push( generateMenuObject( "Manual" ) );
				
				//Generate menu html
				var menuHTML = "";			
				for (var i = 0; i < menus.length; ++i){
					menuHTML += generateMenuOption(menus[i].id, i) + " ";
				}
				
				//Insert html
				document.getElementById("menu").innerHTML = menuHTML;
			}

			//Generate a menu object given an ID	
			function generateMenuObject(id){
				var retval = new Object();
				retval.id = id;
				return retval;
			}

			//Generate a menu option's html given it's id and index
			function generateMenuOption(id, index){
				return "<span class=\"gc_s_menu_option\" onmousedown=\"setVisibleForm("+index+")\">"+id+"</span>";
			}

			//Set submission form to display, hide all others
			function setVisibleForm(index){
				for (var i = 0; i < menus.length; ++i){
					document.getElementById(menus[i].id).style.display = "none";
				}
				document.getElementById(menus[index].id).style.display = "block";
			}
		</script>
	</head>	
	<body onload="init()">
		<div id="container">
			<div id="menu">
			</div>
			<div class="subForm" id="Audio">
				<h1>Audio</h1>
				<form method="post" action="submission.php">
				<input type="hidden" name="sType" value="subAudio" />

				<h2>Audio file URL</h2>
				<input name="sContentA" />
				<span class="example">http://www.domain.example/audio-file.mp3</span>
				<hr />
				<h2>Song title / artist</h2>
				<input name="sTitle" />
				<span class="example">The Beatles: Yellow Submarine</span>

				<h2>Source name</h2>
				<input name="sSourceText" />
				<span class="example">Tom's blog</span>

				<h2>Source URL</h2>
				<input name="sSourceURL" />
				<span class="example">http://blog.thomaspurnell.com</span>

				<h2>Caption</h2>
				<textarea name="sCaption"></textarea>
				<span class="example">This song reminds me of the time I listened to this song</span>
				
				<p><input type="submit" value="submit" /></p>
				</form>
			</div>

			<div class="subForm" id="Image">
				<h1>Image</h1>
				<form method="post" action="submission.php">
				<input type="hidden" name="sType" value="subImage" />
				<h2>Image URL</h2>
				<input name="sContentA" />
				<span class="example">http://www.domain.example/photo.jpg</span>
				<hr />	
				<h2>Image title</h2>
				<input name="sTitle" />
				<span class="example">Photo of my pet rock</span>
	
				<h2>Source name</h2>
				<input name="sSourceText" />
				<span class="example">Tom's blog</span>

				<h2>Source URL</h2>
				<input name="sSourceURL" />
				<span class="example">http://blog.thomaspurnell.com</span>

				<h2>Caption</h2>
				<textarea name="sCaption"></textarea>
				<span class="example">This song reminds me of the time I listened to this song</span>
				
				<p><input type="submit" value="submit" /></p>
				</form>
			</div>

			<div class="subForm" id="Quote">
				<h1>Quote</h1>				
				<form method="post" action="submission.php">
				<input type="hidden" name="sType" value="subQuote" />
	
				<h2>Quote</h2>
				<textarea name="sContentA"></textarea>
				<span class="example">Life is like a box of unsweetened carob pieces</span>
				<hr />
				<input type="hidden" name="sTitle" value="QUOTE"/>

				<h2>Source name</h2>
				<input name="sSourceText" />
				<span class="example">Tom Gump</span>

				<h2>Source URL</h2>
				<input name="sSourceURL" />
				<span class="example">http://blog.thomaspurnell.com</span>

				<h2>Caption</h2>
				<textarea name="sCaption"></textarea>
				<span class="example">This is perhaps the greatest thing Tom has ever said</span>
				
				<p><input type="submit" value="submit" /></p>
				</form>
			</div>

			<div class="subForm" id="Video">
				<h1>Video</h1>
				<form method="post" action="submission.php">
				<input type="hidden" name="sType" value="subVideo" />
				<h2>Youtube URL</h2>
				<input name="sContentA" />
				<span class="example">http://www.youtube.com/watch?v=yphAoG3iH6w</span>
				<hr />				
				<h2>Title</h2>
				<input name="sTitle" />
				<span class="example">King of the pond</span>

				<h2>Source name</h2>
				<input name="sSourceText" />
				<span class="example">Sarah's blog</span>

				<h2>Source URL</h2>
				<input name="sSourceURL" />
				<span class="example">http://www.dendrea.com</span>
	
				<h2>Caption</h2>
				<textarea name="sCaption"></textarea>
				<span class="example">This song reminds me of the time I listened to this song</span>
				
				<p><input type="submit" value="submit" /></p>

				</form>
			</div>

			<div class="subForm" id="Manual">
				<h1>Manual</h1>
				<form method="post" action="submission.php">
				<input type="hidden" name="sType" value="subManual" />
				<h2>HTML content</h2>
				<textarea name="sContentA"></textarea>
				<span class="example">(Paste your HTML code here)</span>
				<hr />	
				<h2>Entry title</h2>
				<input name="sTitle" />
				<span class="example">Title for this entry</span>
				
				<h2>Source name</h2>
				<input name="sSourceText" />
				<span class="example">Tom's Site</span>

				<h2>Source URL</h2>
				<input name="sSourceURL" />
				<span class="example">http://www.thomaspurnell.com</span>

				<h2>Caption</h2>
				<textarea name="sCaption"></textarea>
				<span class="example">I found this somewhere :)</span>
				
				<p><input type="submit" value="submit" /></p>
				</form>
			</div>
		</div>
	</body>
</html>
<?php  ?>
